home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Kant Generator Pro 1.2 / src / Shell ƒ / pict utilities.c < prev    next >
C/C++ Source or Header  |  1994-10-13  |  860b  |  27 lines

  1. #include "pict utilities.h"
  2.  
  3. PicHandle DrawThePicture(PicHandle thePict, short whichPict, short x, short y)
  4. /* a standard routine for loading a picture (if necessary) and then drawing it */
  5. {
  6.     Rect            temp;
  7.     
  8.     if (thePict==0L)        /* get it if it doesn't exist */
  9.         thePict=(PicHandle)GetPicture(whichPict);
  10.     
  11.     HLock((Handle)thePict);        /* lock it down for dereferencing to get picture bounds */
  12.     temp.top=y;
  13.     temp.left=x;
  14.     temp.bottom=temp.top+(**thePict).picFrame.bottom-(**thePict).picFrame.top;
  15.     temp.right=temp.left+(**thePict).picFrame.right-(**thePict).picFrame.left;
  16.     DrawPicture(thePict, &temp);    /* draw picture at (x,y) */
  17.     HUnlock((Handle)thePict);        /* unlock for better memory management */
  18.     return thePict;
  19. }
  20.  
  21. PicHandle ReleaseThePict(PicHandle thePict)
  22. {
  23.     if (thePict!=0L)    /* if exists, release it */
  24.         ReleaseResource((Handle)thePict);
  25.     return 0L;
  26. }
  27.